package com.txh.blog.controller.admin;

import com.txh.blog.service.AdminService;
import com.txh.blog.service.ArticleService;
import com.txh.blog.vo.ArticelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;
    @Autowired
    private ArticleService articleService;

    @RequestMapping("/index")
    public String index(){
        return "admin/index";
    }

    @RequestMapping("/welcome")
    public String myDeskop(Model model){
        Map<String,Object> indexData = adminService.getIndexData();
        List<ArticelVo> articelVoList = articleService.partArticelList();
        model.addAttribute("data",indexData);
        model.addAttribute("articles",articelVoList);
        return "admin/welcome";
    }
}
